package edu.szte.ovrt.datahandler.model;

import java.util.List;

import static edu.szte.ovrt.datahandler.test.ModelFactory.*;

import org.junit.Test;

import static org.junit.Assert.*;

public class SectionTest {

	@Test
	public void testGetItems() {
		final Section section = new Section(null);
		final List<Item> items1 = section.getItems();
		assertNotNull(items1);
		final List<Item> items2 = section.getItems();
		assertSame(items1, items2);
	}

	@Test
	public void testNamePropertyDefault() {
		final Section section = new Section(null);
		assertEquals("", section.getName());
	}

	@Test
	public void testNamePropertyGetSet() {
		final Section section = new Section(null);
		final String newName = "testName";
		section.setName(newName);
		assertEquals(newName, section.getName());
	}

	@Test
	public void testEqualsEmpty() {
		final Section section1 = createSectionEmpty(null);
		final Section section2 = createSectionEmpty(null);
		assertTrue(section1.equals(section2));
	}

	@Test
	public void testEqualsOneItem() {
		final Section section1 = createSectionWithOneItem(null);
		final Section section2 = createSectionWithOneItem(null);
		assertTrue(section1.equals(section2));
	}

	@Test
	public void testEqualsMoreItems() {
		final Section section1 = createSectionWithMoreItems(null);
		final Section section2 = createSectionWithMoreItems(null);
		assertTrue(section1.equals(section2));
	}

	@Test
	public void testEqualsMoreItemsDifferentName() {
		final Section section1 = createSectionWithMoreItems(null);
		final Section section2 = createSectionWithMoreItems(null);
		section2.setName("Different name");
		assertFalse(section1.equals(section2));
	}

	@Test
	public void testEqualsNull() {
		final Section section1 = createSectionWithMoreItems(null);
		assertFalse(section1.equals(null));
	}

	@Test
	public void testEqualsOther() {
		final Section section1 = createSectionWithMoreItems(null);
		assertFalse(section1.equals(new Object()));
	}

	@Test
	public void testEqualsFalse() {
		final Section section1 = createSectionWithOneItem(null);
		final Section section2 = createSectionWithMoreItems(null);
		assertFalse(section1.equals(section2));
	}
}
